package org.visionlibrary.image.geomtric.util;

/**
 * Klasa realizujaca funkcjonalnosc parowania dwoch obiektow. Kontener ten
 * przechowuje dwie wartosci.
 */
public class Pair<T, S> {
	private T left;
	private S right;

	public Pair() {
	}

	public Pair(T left, S right) throws NullPointerException {
		if (left == null)
			throw new NullPointerException("Left Pair element is null");
		if (right == null)
			throw new NullPointerException("Right Pair element is null");
		this.left = left;
		this.right = right;
	}

	public T getLeft() {
		return left;
	}

	public S getRight() {
		return right;
	}

	public void setLeft(T left) {
		this.left = left;
	}

	public void setRight(S right) {
		this.right = right;
	}
	
	public static Pair<Integer, Integer> packInt(int left, int right) {
		return new Pair<Integer, Integer>(new Integer(left), new Integer(right));
	}
	
	public static Pair<Float, Float> packFloat(float left, float right) {
		return new Pair<Float, Float>(new Float(left), new Float(right));
	}
	
	public static Pair<Double, Double> packDouble(double left, double right) {
		return new Pair<Double, Double>(new Double(left), new Double(right));
	}
	
	public static Pair<Short, Short> packShort(short left, short right) {
		return new Pair<Short, Short>(new Short(left), new Short(right));
	}
}
